package com.xiaohu.myspace.utils.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class MessageFilter implements Filter {
	private String textType = "utf-8";

	public void init(FilterConfig filterConfig) throws ServletException {
		textType = filterConfig.getInitParameter("encoding");

	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain arg2) throws IOException, ServletException {
		request.setCharacterEncoding(textType);
		response.setCharacterEncoding(textType);
		arg2.doFilter(request, response);
	}

	public void destroy() {
		textType = "utf-8";
	}

}
